package ge.telasi.tasks.model;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 * @author dimitri
 */
@Entity
@Table(name = "task_receivers")
public class TaskReceiver extends Modifiable implements Serializable {
    private static final long serialVersionUID = -2382655835535101855L;

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TASK_RECEIVERS_SEQ")
    @SequenceGenerator(name = "TASK_RECEIVERS_SEQ", sequenceName = "TASK_RECEIVERS_SEQ", allocationSize = 1)
    private Long id;
    @ManyToOne
    @JoinColumn(name = "task_id")
    private Task task;
    @ManyToOne
    @JoinColumn(name = "user_id")
    private User user;
    @ManyToOne
    @JoinColumn(name = "group_id")
    private Group group;
    @Column(name = "is_copy")
    private int copyBit;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Task getTask() {
        return task;
    }

    public void setTask(Task task) {
        this.task = task;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Group getGroup() {
        return group;
    }

    public void setGroup(Group group) {
        this.group = group;
    }

    public boolean isCopy() {
        return copyBit == 1;
    }

    public void setCopy(boolean copy) {
        this.copyBit = copy ? 1 : 0;
    }

}
